﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data.Entity;
using MSD.WL.Site.Models;

namespace MSD.WL.Site.Controllers
{
    [Authorize]
    public class ServiceController : Controller
    {
        private EMSContext db = new EMSContext();
        // GET: Service
        #region 联系记录
        public ActionResult ConnRecords()
        {
            return View();
        }
        //获取数据
        [HttpPost]
        public JsonResult getConnRecords(int offset,int limit)
        {
            var relRecord = db.RelRecord as IQueryable<RelRecord>;
            var connRecords = relRecord.Select(x => new { ID = x.ID, CustomerCode = x.CustomerCode, RelDate = x.RelDate, RelManner = x.RelManner, Linkman = x.Linkman, TelephoneCode = x.TelephoneCode, NextDate = x.NextDate, RelContent = x.RelContent, FeeInfo = x.FeeInfo }).ToList();
            var total = connRecords.Count();
            var rows = connRecords.OrderBy(x => x.ID).Skip(offset).Take(limit).ToList();
            return Json(new { total=total,rows=rows});
        }
        #endregion

        #region 售后服务
        public ActionResult afterServer()
        {
            return View();
        }

        [HttpPost]
        public JsonResult getafterServer(int offset,int limit)
        {
            var aftServer = db.AfterServer as IQueryable<AfterServer>;
            var aftServerRecords = aftServer.Select(x => new { ID = x.ID, CustomerCode = x.CustomerCode, SerDate = x.SerDate, EmployeeCode = x.EmployeeCode, Linkman = x.Linkman, TelephoneCode = x.TelephoneCode, SerDays = x.SerDays, SerContent = x.SerContent, Resolvent = x.Resolvent }).ToList();
            var total = aftServerRecords.Count();
            var rows = aftServerRecords.OrderBy(x => x.ID).Skip(offset).Take(limit).ToList();
            return Json(new { total=total,rows=rows});
        }
        #endregion
    }
}